home *** CD-ROM | disk | FTP | other *** search
- #ifndef _argc_Receiver_
- #define _argc_Receiver_
-
-
- #ifdef ReinvokeMain
-
- #define main mainarg
-
- // If the argcQuitFlag global is TRUE, we've received a Quit event,
- // and the command should abort as gracefully as possible.
-
- extern Boolean argcQuitFlag;
-
- // Your "main" procedure will be called by the glue code which
- // retrieves the argc/argv arguments whenever a set of arguments
- // arrives. Note, however, that your main isn't the *real* main
- // procedure. The #define above is actually changing the name of
- // your main procedure to "mainarg" and my glue code is calling
- // it as a subroutine.
- //
- // While this approach solves several problems inherent in the
- // use of the earlier argcReceiver scheme, it creates one new
- // challenge for developers: since your main procedure can be
- // called repeatedly during a single invocation of your program,
- // you need to make sure that your code cleans-up behind itself
- // each time it completes. This means, for instance, that you've
- // got to manually reinitialize any globals you may have created.
- // Otherwise the values from the previous invocation of your
- // "main" procedure will still be lingering in the globals,
- // possibly causing your code problems you wouldn't normally
- // expect.
- //
- // If the Mac OS handled processes differently, none of this would
- // be necessary, of course. (Sigh.)
-
- extern int mainarg(int argc, char **argv);
-
- #else
-
- void argcReceiver(int *argcRcvd, char ***argvRcvd);
-
- #endif
-
-
- #endif